/* Main.cc -- Principal do GEARJoystick
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogo.ramos@usp.br>
 * GEAR - Grupo de Estudos Avançados em Robótica
 * <http://www.sel.eesc.usp.br/gear>
 *
 * This file is part of GEARJoystick.
 * 
 * GEARJoystick is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3 of the
 * License.
 * 
 * GEARJoystick is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include <unistd.h>
#include <stdlib.h>

#include "GJJoy.hh"
#include "CommLineArgs.hh"

int
main(int argc, char *argv[])
{
    GJJoy gjjoy;
    CommLineArgs line_args;

    int done = 0;
    int rc = 0;

    if (line_args.ParseArgs( argc, argv ))
	return EXIT_SUCCESS;
    
    gjjoy.Init(line_args);

    while (!done) {
	rc = gjjoy.readJoystickEvent();
	usleep(1000);
	if (rc == 1) {
	    gjjoy.processEvent();
	    gjjoy.sendCommandToMedula();
	}
    }

    return EXIT_SUCCESS;
}
